<?php
/**
 * phpxw 框架基础类
 * @author xuwu<xuwu@ulkoo.com>
 * 2010-5-21 12:26:14
 */ 
class appinit
{
    
	public function run($app){
	   $mod=empty($_GET['m'])?'index':trim($_GET['m']); // 模块名
	   $act=empty($_GET['a'])?'index':trim($_GET['a']); // 方法名
	   require $app['classpath'].'class.phpxwsystem.php';
	   if(file_exists($app['classpath'].'class.'.$mod.'.php')){
	       require $app['classpath'].'class.'.$mod.'.php';
	   }
	   if(file_exists($app['modapth'].'mod_'.$mod.'.php')){
           require $app['modapth'].'mod_'.$mod.'.php';
           // 初始化类
           $modname='mod_'.$mod;
           $actname='action_'.$act;
           if(class_exists($modname)){
                $d=new $modname();
                $app['mod']=$mod;
                $app['act']=$act;
                $app['modname']=$modname;
                $app['actname']=$actname;
                $d->appinit($app);
                if(method_exists($d,$actname)){
                    $d->$actname();
                    $d->template();
                }else{
                    trigger_error($mod.' mod is not found.',E_USER_ERROR);
                }
           }else{
                trigger_error($mod.' mod is not found.',E_USER_ERROR);
           }
           
       }else{
            trigger_error($mod.' file is not found.',E_USER_ERROR);
       }
	}
	
}